package com.fanyue.modules.face.controller;

import com.fanyue.core.request.R;
import com.fanyue.modules.face.service.FaceEngineService;
import com.fanyue.modules.face.service.IFaceService;
import com.fanyue.modules.face.vo.FaceVO;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@Tag(name = "人脸服务", description = "人脸服务")
@RestController
@AllArgsConstructor
@RequestMapping("/face")
public class FaceController {

	private final IFaceService faceService;

	@GetMapping("/userInfo")
	public R userInfo(@RequestParam("userId") Long userId) {
		return faceService.userInfo(userId);
	}

	@GetMapping("/featureList")
	public R featureList() {
		return faceService.featureList();
	}

	@PostMapping("/extract/feature")
	public R extractFeature(
		@RequestParam("userId") Long userId,
		@RequestParam("faceFile") MultipartFile file
	) {
		return faceService.extractFeature("multipartFile", userId, file, null);
	}

	@PostMapping("/compare/feature")
	public R extractFeature(
		@RequestBody FaceVO faceVO
	) {
		return faceService.compareFeature(faceVO, 1);
	}

	@PostMapping("/delete/feature")
	public R deleteFeature(@RequestBody FaceVO faceVO) {
		Long userId = faceVO.getUserId();
		return faceService.deleteFeature(userId);
	}

}
